using FW;
using UnityEngine;

//键鼠输入
public class KeyMouseInput
{
    public Player owner;
    public bool _isMoving;

    public Vector3 _vector3 = new Vector3();
    public bool _isJumping;


    public float targetDright;
    public float targetDup;
    public float targetThrustVec;

    public float _velocityDUp;
    public float _velocityDright;
    public float _velocityDThrustVec;

    public float isRun;
    public float Dmag;
    public float Dvec;

    public bool isinputEnabled = true;
    public bool isBanMove = false;
    public bool isRoll = false;

    public bool isR0L1;

    public bool isRightMouseButtonPress;
    public bool leftAttack;
    public bool rightAttack;
    public void Init(Player player)
    {

    }

    public KeyMouseInput(Player player)
    {
        owner = player;
    }
    public void DoUpdate()
    {
        if (Input.GetMouseButtonDown(1))
        {
            leftAttack = true;
        }
        if(Input.GetMouseButtonUp(1))
        {
            leftAttack = false;
        }
        rightAttack = Input.GetMouseButtonDown(0);
        isR0L1 = Input.GetMouseButtonDown(1);
        isRun = Input.GetKey(KeyCode.LeftShift) ? 2f :1f;
        _isJumping = Input.GetKeyDown(KeyCode.Space);
        targetDright = isRun * ((Input.GetKey(KeyCode.D) ? 1.0f : 0) - (Input.GetKey(KeyCode.A) ? 1.0f : 0));
        targetDup = isRun*  ((Input.GetKey(KeyCode.W) ? 1.0f : 0) - (Input.GetKey(KeyCode.S) ? 1.0f : 0));
        //if(targetDright!=0f || targetDup != 0f)
        //{
        //    leftAttack = false;
        //    rightAttack = false;
        //}
        _vector3.x = Mathf.SmoothDamp(_vector3.x, targetDright,ref _velocityDright, 0.1f);
        _vector3.z = Mathf.SmoothDamp(_vector3.z, targetDup,ref _velocityDUp, 0.1f);
        Dmag = Mathf.Sqrt(_vector3.x * _vector3.x + _vector3.z * _vector3.z);

        isRoll = Input.GetKeyDown(KeyCode.LeftShift) && (Dmag>0);
    }

}